package music.play.index;

import com.jfinal.core.Controller;
import com.jfinal.core.Path;
import com.jfinal.log.Log;
import com.jfinal.upload.UploadFile;
import music.play.config.JsonResult;
import music.play.config.PlayerEnum;
import music.play.util.AudioUtil;
import music.play.util.JschUtil;

/**
 * 本 demo 仅表达最为粗浅的 jfinal 用法，更为有价值的实用的企业级用法
 * 详见 JFinal 俱乐部: https://jfinal.com/club
 * <p>
 * IndexController
 */
@Path(value = "/", viewPath = "/index")
public class IndexController extends Controller {

    private static final Log log = Log.getLog(Controller.class);

    public void index() {
        render("index.html");
    }

    public void list() {
        renderJson(AudioUtil.AudioList());
    }

    public void play() {
        AudioUtil.Play();
        renderJson(JsonResult.success("执行播放操作"));
    }

    public void stop() {
        AudioUtil.Stop();
        renderJson(JsonResult.success("执行停止操作"));
    }

    public void del() {
        renderJson(AudioUtil.AudioDel(getPara("fileName")));
    }

    public void upload() {
        UploadFile uploadFile = getFile();
        renderJson(uploadFile.getUploadPath());
    }
}